/**
 * @Author: ZFEason
 * @Date: 2023-07-11 14:00:01
 * @LastEditors: ZFEason
 * @LastEditTime: 2023-07-20 10:30:39
 * @FilePath: /ift-economy-network-h5/src/pages/project-scheduling/index.tsx
 * @Description:
 */

import { Image } from "antd-mobile";
import { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import Styles from "./index.module.less";
import applicationScheduling from "@/assets/image/application_scheduling.png";
import departmentScheduling from "@/assets/image/department_scheduling.png";
import resolvedMatter from "@/assets/image/resolved_matter.png";
import progress from "@/assets/image/progress.png";
import feedback from "@/assets/image/feedback.png";
import progressNormal from "@/assets/image/progress_normal.png";
import feedbackNormal from "@/assets/image/feedback_normal.png";
import { departItemsOverview } from "@/service/project-scheduling";

const Index: React.FC<any> = () => {
  const navigate = useNavigate();

  const [schedulingData, setSchedulingData] = useState<any>({});
  const tracking = schedulingData?.taskItemCount ?? 0;
  const matters = schedulingData?.taskItemCount ?? 0;
  const no_feedback = schedulingData?.undoneCount ?? 0;
  const in_progress = schedulingData?.pushingCount ?? 0;
  const completed = schedulingData?.doneCount ?? 0;

  const gotoProjectScheduling = () => {
    navigate(`/meeting-situation?tracking=${tracking}&matters=${matters}`);
  };
  const gotoMeetingSituation = () => {
    navigate(
      `/meeting-situation?no_feedback=${no_feedback}&in_progress=${in_progress}&completed=${completed}`
    );
  };

  const onClickApplySchedule = () => {
    console.log("department----", schedulingData.department);
    navigate("/apply-scheduling?role=1");
  };

  const getProjectSchedulingData = async () => {
    const upRes: any = await departItemsOverview({ dispatchType: 1 });
    const normalRes: any = await departItemsOverview({ dispatchType: 2 });
    (upRes?.code === 0 || normalRes?.code === 0) &&
      setSchedulingData({ ...(upRes?.data ?? {}), ...(normalRes?.data ?? {}) });
  };

  useEffect(() => {
    getProjectSchedulingData();
  }, []);

  return (
    <div className={Styles.container}>
      <div className={Styles.title}>上会调度</div>

      <div className={Styles.scheduling_container}>
        <div className={Styles.scheduling_title}>调度情况跟踪</div>
        <div className={Styles.scheduling_btn_container}>
          <div className={Styles.left_btn} onClick={onClickApplySchedule}>
            <div className={Styles.left_btn_title}>部门申请调度</div>
            <Image
              className={Styles.left_btn_img}
              src={applicationScheduling}
            />
          </div>
          <div className={Styles.right_view}>
            <div
              className={Styles.right_up_btn}
              onClick={gotoProjectScheduling}
            >
              <div className={Styles.right_up_btn_inner_view}>
                <Image
                  className={Styles.right_up_btn_img}
                  src={departmentScheduling}
                />
                <div className={Styles.right_container}>
                  <div className={Styles.title}>本部门调度跟踪</div>
                  <div
                    className={Styles.message}
                  >{`共 ${tracking} 条信息`}</div>
                </div>
              </div>
            </div>
            <div
              className={Styles.right_bottom_btn}
              onClick={gotoProjectScheduling}
            >
              <div className={Styles.right_bottom_btn_inner_view}>
                <Image
                  className={Styles.right_bottom_btn_img}
                  src={resolvedMatter}
                />
                <div className={Styles.right_container}>
                  <div className={Styles.title}>需协调解决事项</div>
                  <div className={Styles.message}>{`共 ${matters} 条信息`}</div>
                </div>
              </div>
            </div>
          </div>
        </div>

        <div className={Styles.scheduling_title}>会议落实情况</div>

        <div className={Styles.meeting_container}>
          <div className={Styles.right_up_btn} onClick={gotoMeetingSituation}>
            <div className={Styles.right_up_btn_inner_view}>
              <Image className={Styles.right_up_btn_img} src={feedback} />
              <div className={Styles.right_container}>
                <div className={Styles.title}>未反馈</div>
                <div
                  className={Styles.message}
                >{`共 ${no_feedback} 条信息`}</div>
              </div>
            </div>
          </div>
          <div
            className={Styles.right_bottom_btn}
            onClick={gotoMeetingSituation}
          >
            <div className={Styles.right_bottom_btn_inner_view}>
              <Image className={Styles.right_bottom_btn_img} src={progress} />
              <div className={Styles.right_container}>
                <div className={Styles.title}>推进中</div>
                <div
                  className={Styles.message}
                >{`共 ${in_progress} 条信息`}</div>
              </div>
            </div>
          </div>
        </div>
      </div>

      <div className={Styles.title}>常态化调度</div>

      <div
        className={`${Styles.scheduling_container} ${Styles.normalized_scheduling}`}
      >
        <div className={Styles.scheduling_title}>常态化调度</div>

        <div className={Styles.meeting_container}>
          <div className={Styles.right_up_btn}>
            <div className={Styles.right_up_btn_inner_view}>
              <Image className={Styles.right_up_btn_img} src={feedbackNormal} />
              <div className={Styles.right_container}>
                <div className={Styles.title}>未反馈</div>
                <div
                  className={Styles.message}
                >{`共 ${no_feedback} 条信息`}</div>
              </div>
            </div>
          </div>
          <div className={Styles.right_bottom_btn}>
            <div className={Styles.right_bottom_btn_inner_view}>
              <Image
                className={Styles.right_bottom_btn_img}
                src={progressNormal}
              />
              <div className={Styles.right_container}>
                <div className={Styles.title}>推进中</div>
                <div
                  className={Styles.message}
                >{`共 ${in_progress} 条信息`}</div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
};
export default Index;
